package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.TrainingCourse;
import com.ruoyi.personnel.mapper.TrainingCourseMapper;
import com.ruoyi.personnel.service.ITrainingCourseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 培训课程记录Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-25
 */
@Service
public class TrainingCourseServiceImpl extends ServiceImpl<TrainingCourseMapper, TrainingCourse> implements ITrainingCourseService {

    @Override
    public List<TrainingCourse> queryList(TrainingCourse trainingCourse) {
        LambdaQueryWrapper<TrainingCourse> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(trainingCourse.getName())){
            lqw.like(TrainingCourse::getName ,trainingCourse.getName());
        }
        if (StringUtils.isNotBlank(trainingCourse.getJobNumber())){
            lqw.eq(TrainingCourse::getJobNumber ,trainingCourse.getJobNumber());
        }
        if (StringUtils.isNotBlank(trainingCourse.getPersonnelId())){
            lqw.eq(TrainingCourse::getPersonnelId ,trainingCourse.getPersonnelId());
        }
        if (StringUtils.isNotBlank(trainingCourse.getTrainingName())){
            lqw.like(TrainingCourse::getTrainingName ,trainingCourse.getTrainingName());
        }
        if (StringUtils.isNotBlank(trainingCourse.getTrainingType())){
            lqw.eq(TrainingCourse::getTrainingType ,trainingCourse.getTrainingType());
        }
        if (StringUtils.isNotBlank(trainingCourse.getTrainingOffice())){
            lqw.eq(TrainingCourse::getTrainingOffice ,trainingCourse.getTrainingOffice());
        }
        if (StringUtils.isNotBlank(trainingCourse.getTrainingStart())){
            lqw.eq(TrainingCourse::getTrainingStart ,trainingCourse.getTrainingStart());
        }
        if (StringUtils.isNotBlank(trainingCourse.getTrainingEnd())){
            lqw.eq(TrainingCourse::getTrainingEnd ,trainingCourse.getTrainingEnd());
        }
        if (StringUtils.isNotBlank(trainingCourse.getYear())){
            lqw.eq(TrainingCourse::getYear ,trainingCourse.getYear());
        }
        if (StringUtils.isNotBlank(trainingCourse.getCredit())){
            lqw.eq(TrainingCourse::getCredit ,trainingCourse.getCredit());
        }
        if (StringUtils.isNotBlank(trainingCourse.getIsCalculate())){
            lqw.eq(TrainingCourse::getIsCalculate ,trainingCourse.getIsCalculate());
        }
        if (StringUtils.isNotBlank(trainingCourse.getTrainingLevel())){
            lqw.eq(TrainingCourse::getTrainingLevel ,trainingCourse.getTrainingLevel());
        }
        if (StringUtils.isNotBlank(trainingCourse.getStatus())){
            lqw.eq(TrainingCourse::getStatus ,trainingCourse.getStatus());
        }
        return this.list(lqw);
    }
}
